import {actions} from '../base';
import Vue from 'vue';

let url = 'admin/api/pay-channel';

export default {
    namespaced: true,
    state: {
        all: [],
        options: {
            status: [
                {label: '关闭', value: 0},
                {label: '正常', value: 1},
            ],
            channel: {
                alipay: {label: '支付宝', value: 'alipay', class: 'primary',},
                wechat: {label: '微信', value: 'wechat', class: 'primary',},
                helloNow: {label: '你好支付', value: 'helloNow', class: 'primary',},
                adapay: {label: 'Adapay', value: 'adapay', class: 'primary',},
                guanggu: {label: '光谷', value: 'guanggu', class: 'primary',},
                yajie: {label: '亚捷', value: 'yajie', class: 'primary',},
            },
        },
        request: {
            all: false,
        }
    },
    mutations: {
        SET_ALL (state, data) {
            state.all = data;
        },
        SET_REQUESTING (state, name) {
            state.request[name] = true;
        },
        SET_REQUESTED (state, name) {
            state.request[name] = false;
        }
    },
    actions: Object.assign({}, actions(url), {
        GetCertFiles({commit}, filter = {}) {
            return Vue.axios.get(`${url}/cert-files`);
        },
        GetQuickSwitch ({commit}) {
            return Vue.axios.get(`${url}/quick-switch`);
        },
        UpdateQuickSwitch ({commit}, data) {
            return Vue.axios.post(`${url}/quick-switch`, data);
        },
    }),
};
